package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.ApprovalDefineItem;
import com.eling.elcms.travel.model.view.ApprovalDefineItemView;
import com.eling.elcms.travel.service.IApprovalDefineItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class ApprovalDefineItemController extends BaseFormController{
	
	@Autowired 
	private IApprovalDefineItemService approvalDefineItemService;
	
	@RequestMapping("/api/approvaldefineitem/save")
	@ResponseBody
	public ApprovalDefineItem save(@ModelAttribute@ModelFilling ApprovalDefineItem ApprovalDefineItem) {
	  return approvalDefineItemService.save(ApprovalDefineItem);
	}
	
	@RequestMapping("/api/approvaldefineitem/saveInDefine")
	@ResponseBody
	public ApprovalDefineItem saveInDefine(@ModelAttribute@ModelFilling ApprovalDefineItem ApprovalDefineItem) {
	  return approvalDefineItemService.saveInDefine(ApprovalDefineItem);
	}
	
	
	@RequestMapping("/api/approvaldefineitem/{pkApprovalDefineItem}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkApprovalDefineItem) {
		approvalDefineItemService.remove(pkApprovalDefineItem);
	   return new Msg("删除成功");
	}
	
	    
	@RequestMapping("/api/approvaldefineitem/query")
	@ResponseBody
	public List<ApprovalDefineItem> query(@ModelAttribute ApprovalDefineItem cond){
		return approvalDefineItemService.query(cond);
	  }
	
	@RequestMapping("/api/approvaldefineitem/search*")
	@ResponseBody
	public List<ApprovalDefineItem> search(@ModelAttribute SearchCondition sc){
		return approvalDefineItemService.search(sc);
	  }
	
	/**
	 * 审批流程配置子表查询
	 * 
	 * **/
	@RequestMapping("/api/approvaldefineitem/queryall")
	@ResponseBody
	public List<ApprovalDefineItemView> queryAll(@ModelAttribute ApprovalDefineItem cond){
		return approvalDefineItemService.queryAll(cond);
	  }
	
	/**
	 * 审批流程配置子表保存
	 * 
	 * **/
	@RequestMapping("/api/approvaldefineitem/saveall")
	@ResponseBody
	public ApprovalDefineItem saveAll(@ModelAttribute ApprovalDefineItem ApprovalDefineItem,
			@RequestParam(value="pkPersonalInfo") Long pkPersonalInfo) {
	  return approvalDefineItemService.saveAll(ApprovalDefineItem,pkPersonalInfo);
	}
}
